//回调成功
DingTalkPC.ready(function (res) {
    DingTalkPC.runtime.permission.requestAuthCode({
        corpId: _config.corpId,
        onSuccess: function (info) {
            $.ajax({
                url: 'autoLogin?code=' + info.code+"&flag=0",
                type: 'GET',
                success: function (data, status, xhr) {
                    $.ajax({
                        url: "userInfo",
                        type: "POST",
                        data: {data: data},
                        datatype: "json",
                        success: function (data, status, xhr) {
                            if (data == "false") {
                                DingTalkPC.device.notification.alert({
                                    message: "数据获取失败,请重试...",
                                    title: "提示",//可传空
                                    buttonName: "确定",
                                    onSuccess: function () {
                                        DingTalkPC.biz.navigation.close({
                                            onSuccess: function (result) {
                                            },
                                            onFail: function (err) {
                                            }
                                        });
                                    },
                                    onFail: function (err) {
                                    }
                                });
                            } else {
                                window.location.href = "computer.jsp";
                            }
                        },
                        error: function (xhr, errorType, error) {
                            alert("用户信息上传失败:" + errorType + ', ' + error);
                        },
                    });

                },
                error: function (xhr, errorType, error) {
                    alert("获取用户信息失败:" + errorType + ', ' + error);
                }
            });
        },
        onFail: function (err) {
            alert('获取免登Code失败: ' + JSON.stringify(err));
        }
    });
});

//回调失败
DingTalkPC.error(function (error) {
    DingTalkPC.device.notification.alert({
        message: "回调失败:" + JSON.stringify(error),
        title: "提示",//可传空
        buttonName: "收到",
        onSuccess: function () {
        },
        onFail: function (err) {
        }
    });
});